<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>鸿鑫国际后台管理系统</title>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<link id="easyuiTheme" rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/default.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<!-- 导入ztree类库 -->
<link rel="stylesheet" href="${pageContext.request.contextPath }/js/ztree/zTreeStyle.css" type="text/css" />
<script	src="${pageContext.request.contextPath }/js/ztree/jquery.ztree.all-3.5.js" type="text/javascript"></script>
<script	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"	type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/outOfBounds.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/common.js" type="text/javascript"></script>
<script type="text/javascript">
	// 初始化ztree菜单
	$(function() {
		var setting = {
			data : {
				simpleData : {      
					enable : true
				}
			},
			callback : {
				onClick : onClick
			}
		};
		
		// 基本功能菜单加载
		$.ajax({
			url : '${pageContext.request.contextPath}/admin/function/getmenulist.do',
			type : 'GET',
			dataType : 'json',
			success : function(data) {
//				console.info(data)
				$.fn.zTree.init($("#treeMenu"), setting, data);
			},
			error : function(msg) {
				alert('菜单加载异常!');
			}
		});
		
		
		
		// 页面加载后 右下角 弹出窗口
		window.setTimeout(function(){
			$.messager.show({
				title:"消息提示",
				msg:'欢迎登录，超级管理员！ <a href="javascript:void" onclick="top.showAbout();">联系管理员</a>',
				timeout:5000
			});
		},3000);
		
		
		$("#btnCancel").click(function(){
			$('#editPwdWindow').window('close');
		});
	});

	function onClick(event, treeId, treeNode, clickFlag) {
		// 判断树菜单节点是否含有 page属性
		if (treeNode.page!=undefined && treeNode.page!= "") {
			var content = '<div style="width:100%;height:100%;overflow:hidden;">'
					+ '<iframe src="'
					+ treeNode.page
					+ '" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
			if ($("#tabs").tabs('exists', treeNode.name)) {// 判断tab是否存在
				$('#tabs').tabs('select', treeNode.name); // 切换tab
				var tab = $('#tabs').tabs('getSelected'); 
				$('#tabs').tabs('update', {
				    tab: tab,
				    options: {
				        title: treeNode.name,
				        content: content
				    }
				});
			} else {
				// 开启一个新的tab页面
				$('#tabs').tabs('add', {
					title : treeNode.name,
					content : content,
					closable : true
				});
			}
		}
	}
	
	function click_me(url, name){
		var treeNode = {};
		var content = '<div style="width:100%;height:100%;overflow:hidden;">'
			+ '<iframe src="'
			+ "${pageContext.request.contextPath}/" + url
			+ '" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
		if ($("#tabs").tabs('exists', name)) {// 判断tab是否存在
			$('#tabs').tabs('select', name); // 切换tab
			var tab = $('#tabs').tabs('getSelected'); 
			$('#tabs').tabs('update', {
			    tab: tab,
			    options: {
			        title: name,
			        content: content
			    }
			});
		} else {
			// 开启一个新的tab页面
			$('#tabs').tabs('add', {
				title : name,
				content : content,
				closable : true
			});
		}
	}

	//更改主题效果
	changeTheme = function(themeName) {
		var $easyuiTheme = $('#easyuiTheme');
		var url = $easyuiTheme.attr('href');
		var href = url.substring(0, url.indexOf('themes')) + 'themes/'
				+ themeName + '/easyui.css';
		$easyuiTheme.attr('href', href);
		var $iframe = $('iframe');
		if ($iframe.length > 0) {
			for ( var i = 0; i < $iframe.length; i++) {
				var ifr = $iframe[i];
				$(ifr).contents().find('#easyuiTheme').attr('href', href);
			}
		}
	};
	// 退出登录
	function logoutFun() {
		$.messager
		.confirm('系统提示','您确定要退出本次登录吗?',function(isConfirm) {
			if (isConfirm) {
				//以下填写退出的地址
				$.getJSON("${pageContext.request.contextPath}/authen/logout.do", function(json){
					if(json.success) {
						<%--location.href = '${pageContext.request.contextPath}/admin/login.html';--%>
						location.href = 'http://'+'<%=request.getServerName()%>/admin/login.html';
						/*location.href = 'http://www.sec-hxi.com/admin/login.html';*/
					} else  {
						$.messager.alert("消息","退出系统失败");
					}
				})

			}
		});
	}
	// 修改密码
	function editPassword() {
		$('#editPwdWindow').window('open');
	}
	// 版权信息
	function showAbout(){
		$.messager.alert("成功企业家俱乐部","管理员邮箱: sec-china@hongxinguoji.com");
	}
</script>
</head>

<body class="easyui-layout">

	<div data-options="region:'north',border:false"
		style="height:80px;padding:10px;background:url('${pageContext.request.contextPath}/images/header_bg.png') no-repeat right;">
		<div>
			<!-- 添加logo图片 -->
			<img src="${pageContext.request.contextPath }/images/logo.png"
				border="0" style="width: 67px">
		</div>
		<div id="sessionInfoDiv"style="position: absolute;right: 5px;top:10px;">
			<%--[<strong>${sessionScope.userInfoAdmin.username }</strong>]，欢迎你！--%>
				[<strong>${sessionScope.userInfoAdmin.realname }</strong>]，欢迎你！
		</div>
		<div style="position: absolute; right: 5px; bottom: 10px; ">
			<a href="javascript:void(0);" class="easyui-menubutton"	data-options="menu:'#layout_north_pfMenu',iconCls:'icon-ok'">更换皮肤</a>
			<a href="javascript:void(0);" class="easyui-menubutton" data-options="menu:'#layout_north_kzmbMenu',iconCls:'icon-help'">控制面板</a>
		</div>
		
		<!-- 更换皮肤功能 -->
		<div id="layout_north_pfMenu" style="width: 120px; display: none;">
			<div onclick="changeTheme('default');">default</div>
			<div onclick="changeTheme('gray');">gray</div>
			<div onclick="changeTheme('black');">black</div>
			<div onclick="changeTheme('bootstrap');">bootstrap</div>
			<div onclick="changeTheme('metro');">metro</div>
		</div>
		
		<!-- 控制面板 -->
		<div id="layout_north_kzmbMenu" style="width: 100px; display: none;">
			<div onclick="editPassword();">修改密码</div>
			<div onclick="showAbout();">联系管理员</div>
			<div class="menu-sep"></div>
			<div onclick="logoutFun();">退出系统</div>
		</div>
	</div>
	

	<div data-options="region:'west',split:true,title:'菜单导航'"
		style="width:200px">
		<div class="easyui-accordion" fit="true" border="false">
			<div title="导航菜单" data-options="iconCls:'icon-mini-add'" style="overflow:auto">
				<ul id="treeMenu" class="ztree"></ul>
			</div>
		</div>
	</div>
	
	<!-- 登录后中心区域，暂无 -->
	<div data-options="region:'center'">
		<div id="tabs" fit="true" class="easyui-tabs" border="false">
			<div title="我的控制台" id="subWarp">
			</div>
		</div>
	</div>
	
	<!-- 显示版权等信息 -->
	<div data-options="region:'south',border:false"
		style="height:50px;padding:10px;background:url('${pageContext.request.contextPath}/images/header_bg.png') no-repeat right;">
		<table style="width: 100%;">
			<tbody>
				<tr>
					<td style="width: 300px;">
						<div style="color: #999; font-size: 8pt;">
							成功企业家俱乐部 | Powered by <a target="_blank" href="http://www.sec-hxi.com/">www.sec-hxi.com</a>
						</div>
					</td>
					<%--
					<td style="width: *;" class="co1"><span id="online"
						style="background: url(${pageContext.request.contextPath }/images/online.png) no-repeat left;padding-left:18px;margin-left:3px;font-size:8pt;color:#005590;">在线人数:10000</span>
					</td>
					--%>
				</tr>
			</tbody>
		</table>
	</div>
	
	<!--修改密码窗口-->
    <div id="editPwdWindow" class="easyui-window" title="修改密码" collapsible="false" minimizable="false" modal="true" closed="true" resizable="false"
        maximizable="false" icon="icon-save"  style="width: 300px; height: 160px; padding: 5px;
        background: #fafafa">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <form id="editPasswordForm">
	                <table cellpadding=3>
	                    <tr>
	                        <td>新密码：</td>
	                        <td><input id="txtNewPass" type="Password" class="txt01 easyui-validatebox" 
	                        	required="true" data-options="validType:'length[4,8]'"
	                        /></td>
	                    </tr>
	                    <tr>
	                        <td>确认密码：</td>
	                        <td><input id="txtRePass" type="Password" class="txt01 easyui-validatebox" 
	                        	required="true" data-options="validType:'length[4,8]'"
	                        /></td>
	                    </tr>
	                </table>
                </form>
            </div>
            <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
                <a id="btnEp" class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)" >确定</a> 
                <a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" href="javascript:void(0)">取消</a>
            </div>
        </div>
    </div>
    <script type="text/javascript">
		$("#btnEp").click(function(){
			var v = $("#editPasswordForm").form("validate");
			if(v){//表单校验通过
				var v1 = $("#txtNewPass").val();
				var v2 = $("#txtRePass").val();
				if(v1 == v2){
					var url = "${pageContext.request.contextPath}/admin/changePwd.do";
					$.post(url,{"password":v1},function(data){
						if(data.data == 1){
							//修改密码成功
							$.messager.alert("提示信息","密码修改成功！","info");

						}else{
							$.messager.alert("提示信息","密码修改失败！","warning");
						}
						//关闭修改密码的窗口
						$("#editPwdWindow").window("close");
//						window.location.reload();
					}, "json");
				}else{
					//输入不一致，提示用户输入不一致
					$.messager.alert("提示信息","两次输入密码不一致！","warning");
				}
			}
		});
    </script>
</body>
</html>